package com.yfjin.h264.tcrtc;

import android.content.Context;
import android.widget.FrameLayout;

import com.yfjin.h264.tcrtc.config.RtcConfig;

/**
 * @author jinyf
 */
public class IRtcImpl implements IRtc {


    @Override
    public boolean startRtc(Context context, String roomId, String userId,RtcStatus callback,  FrameLayout vieContiner) {
        RtcManager.Params params = new RtcManager.Params(roomId, "robot"
                , RtcConfig.SDKAPPID, RtcConfig.SECRETKEY
        );
        boolean status=RtcManager.INSTANCE().start(context, params,callback);
        RtcManager.INSTANCE().startRemoteView(userId==null?"null":userId,vieContiner);
        return status;
    }

    @Override
    public void exitRtc() {
        RtcManager.INSTANCE().stop(false);
    }

    @Override
    public void sendMsg(byte[] msg) {
        RtcManager.INSTANCE().sendMsg(msg);
    }

    @Override
    public void sendVideoData(byte[] nv21, int width, int height) {
        RtcManager.INSTANCE().sendVideoData(nv21, width, height);
    }

    @Override
    public void sendAudioData(byte[] pcm, int sampleRate, int channel) {
        RtcManager.INSTANCE().sendAudioData(pcm, sampleRate, channel);
    }
}
